package com.mtoolkit.jdbc.handler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Integer number result set call back handler.
 *
 * @author 	<a href="mailto:shixi.zhang@f-club.com">ZhangShixi</a>
 * @version 1.00, 5/21/2012
 * @since 	JDK1.5
 */
public class IntegerResultSetHandler implements ResultSetHandler<Integer> {

	/**
     * Handles the result set and return integer result.
     * 
     * @param  rs result set.
     * 
     * @return long result.
     * 
     * @throws SQLException if a sql error occurs whiling handle result set.
     */ 
	@Override
	public Integer handle(ResultSet rs) throws SQLException {
		if (rs.next()) {
            return Integer.valueOf(rs.getInt(1));
        } else {
            return null;
        }
	}

}
